package com.ss.common.pojo;

import java.io.Serializable;
import java.util.List;
/**
 * @author lilongshun
 * @date 2010-3-27 上午09:39:01
 */
public class PageResult  implements Serializable{
	private Integer current; // 当前是第几页

	private Integer totalRecord;// 总记录数

	private Integer pageSize; // 每页显示的记录数

	private Integer totalPage=1; // 总页数

	private boolean pre;// 是否有上一页

	private boolean next;// 是否有下一页

	private Integer start;
	
	private Integer end;

	private Integer maxSize;
	
	private List list = null;
	
	private Integer index;//下标[index+i.count]
	
	private boolean isPaging=true;//是否开启分页
	/**
	 * @return the index
	 */
	public Integer getIndex() {
		index= this.current*this.pageSize-this.pageSize;
		return index;
	}

	/**
	 * @param index the index to set
	 */
	public void setIndex(Integer index) {
		this.index = index;
	}

	public PageResult() {
		this.current = 1;
		this.pageSize = 30;
	}

	/**
	 * @return the current
	 */
	public Integer getCurrent() {
		return current;
	}

	/**
	 * @param current the current to set
	 */
	public void setCurrent(Integer current) {
		this.current = current;
	}

	/**
	 * @return the end
	 */
	public Integer getEnd() {
		end=this.getStart() + pageSize;
		return end;
	}

	/**
	 * @param end the end to set
	 */
	public void setEnd(Integer end) {
		this.end = end;
	}

	/**
	 * @return the list
	 */
	public List getList() {
		return list;
	}

	/**
	 * @param list the list to set
	 */
	public void setList(List list) {
		this.list = list;
	}

	/**
	 * @return the next
	 */
	public boolean isNext() {		
		//next = current < totalPage ? true : false;
		return next;
	}

	/**
	 * @param next the next to set
	 */
	public void setNext(boolean next) {
		this.next = next;
	}

	/**
	 * @return the pageSize
	 */
	public Integer getPageSize() {
		return pageSize;
	}

	/**
	 * @param pageSize the pageSize to set
	 */
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * @return the pre
	 */
	public boolean isPre() {
		pre = current > 1 ? true : false;
		return pre;
	}

	/**
	 * @param pre the pre to set
	 */
	public void setPre(boolean pre) {
		this.pre = pre;
	}

	/**
	 * @return the start
	 */
	public Integer getStart() {
		start=(current - 1) * pageSize;
		return start;
	}

	/**
	 * @param start the start to set
	 */
	public void setStart(Integer start) {
		this.start = start;
	}

	/**
	 * @return the totalPage
	 */
	public Integer getTotalPage() {
		//totalPage = (this.totalRecord + this.pageSize - 1) / pageSize;
		return totalPage;
	}

	/**
	 * @param totalPage the totalPage to set
	 */
	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}

	/**
	 * @return the totalRecord
	 */
	public Integer getTotalRecord() {
		return totalRecord;
	}

	/**
	 * 设置总数据条数
	 * @param totalRecord the totalRecord to set
	 */
	public void setTotalRecord(Integer totalRecord) {
		this.totalRecord = totalRecord;		
		//getTotalPage
		totalPage = (this.totalRecord + this.pageSize - 1) / pageSize;		
		//isPre
		pre = current > 1 ? true : false;
		//isNext
		next = current < totalPage ? true : false;		
		//getStart
		start=(current - 1) * pageSize;
		//getEnd
		end=this.getStart() + pageSize;	
		if(getCurrent()>getTotalPage()){
			setCurrent(getTotalPage());
		}
		maxSize=maxSize==null?100:maxSize;
		if(pageSize>maxSize){
			setPageSize(maxSize);
		}
		if(pageSize<0){
			pageSize=15;
		}
	}

	public Integer getMaxSize() {
		return maxSize;
	}

	public void setMaxSize(Integer maxSize) {
		this.maxSize = maxSize;
	}

	public boolean getIsPaging() {
		return isPaging;
	}

	public void setIsPaging(boolean isPaging) {
		this.isPaging = isPaging;
	}

	 

	

	
}
